/**
 * %COPYRIGHT%
 * <p/>
 * %VERSION% %BUILD_DATE%
 */
package net.fredstar.fjutils.math;

/**
 * TODO comments
 * 
 * @author Matthew Blackford - http://www.fredstar.net/
 * @since %FIRST_VERSION% 23/04/2010
 * @version %VERSION%
 */
public class FMath
{
  public static boolean inRange( final int value, final int min, final int max )
  {
    return value >= min && value <= max;
  }
  
  public static boolean inRange( final double value,
                                 final double min,
                                 final double max )
  {
    return value >= min && value <= max;
  }
  
  public static double range( final double value,
                              final double min,
                              final double max )
  {
    return Math.min( Math.max( value, min ), max );
  }
  
  public static float range( final float value, final float min, final float max )
  {
    return Math.min( Math.max( value, min ), max );
  }
  
  public static int range( final int value, final int min, final int max )
  {
    return Math.min( Math.max( value, min ), max );
  }
  
  public static boolean equals( final double value1, final double value2 )
  {
    return FMath.equals( value1, value2, Double.MIN_VALUE );
  }
  
  public static boolean equals( final double value1,
                                final double value2,
                                final double delta )
  {
    return Math.abs( value1 - value2 ) < delta;
  }
}
